{{- define "title" }}
  {{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }} - {{ .Site.Title -}}
{{- end -}}

{{- define "content" -}}
  <div class="page archive">
    <div class="header">
      {{- /* Title */ -}}
      <h1 class="single-title animate__animated animate__pulse animate__faster">
        {{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }}
        <sup>{{- len .Pages -}}</sup>
      </h1>
      {{- /* Total word count */ -}}
      {{- /* See https://github.com/hugo-fixit/FixIt/issues/124 */ -}}
      {{- $localData := newScratch -}}
      {{- range .Pages -}}
        {{- $localData.Add "totalWordCount" .WordCount -}}
      {{- end -}}
      {{- with ($localData.Get "totalWordCount") -}}
        {{- $humanizedNum := . -}}
        {{- if ge $humanizedNum 1000 -}}
          {{- $humanizedNum = printf "%.2fK" (div $humanizedNum 1000.0) -}}
        {{- end -}}
        <p class="single-subtitle total-word-count" title='{{- T "taxonomy.totalwordCount" 1 }}'>
          {{- dict "Class" "fa-regular fa-keyboard fa-fw" | partial "plugin/icon.html" }} {{ T "taxonomy.totalwordCount" (dict "Count" $humanizedNum) -}}
        </p>
      {{- end -}}
    </div>

    {{- /* Paginate */ -}}
    {{- if .Pages -}}
      {{- $pages := .Pages.GroupByDate "2006" -}}
      {{- with .Site.Params.section.paginate | default .Site.Params.paginate -}}
        {{- $pages = $.Paginate $pages . -}}
      {{- else -}}
        {{- $pages = .Paginate $pages -}}
      {{- end -}}
      {{- partial "recently-updated.html" . -}}
      {{- range $pages.PageGroups -}}
        <h2 class="group-title">{{ .Key }}</h2>
        {{- range .Pages -}}
          <article class="archive-item">
            <a href="{{ .RelPermalink }}" class="archive-item-link">{{- .Title -}}</a>
            <span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Date.Format }}'>
              {{- $.Site.Params.section.dateFormat | default "01-02" | .Date.Format -}}
            </span>
          </article>
        {{- end -}}
      {{- end -}}
      {{- partial "paginator.html" . -}}
    {{- end -}}
  </div>
{{- end -}}
